PAGE 1

Row

Clicks-mouse

Keys-keyboard

Row

TreeMap of keyboards keys usage

% letters keys usage

PAGE 2

Row

Clicks mouse in Applications

PAGE 3

Row

Keys keyboard in Applications

---
title: "Trabajo Práctico Personal - InfoVis: uso del mouse y teclado"
author: "ADRIAN PABLO CAFA"
output: 
  flexdashboard::flex_dashboard:
    logo: https://www.itba.edu.ar/wp-content/uploads/2020/03/Marca-ITBA-Color-ALTA.png" width="80" height="40" alt="ITBA"
    orientation: rows
    social: menu
    source_code: embed
---



```{r setup, include=FALSE}
  library(dygraphs)
  library(xts)          # To make the convertion data-frame / xts format
  library(tidyverse)
  library(lubridate)
  library(manipulateWidget)
  library(htmlwidgets)
  library(treemap)
  library(xlsx)
  library(xtable)
  library(dplyr)
  library(d3treeR)
  library(d3Tree)
  library(ggplotlyExtra)
  library(plotly)

# Read the data
data1 <- read.table("C:/Users/ADRIAN CAFA/Desktop/bd_tp_final/mouse_y_teclado_totales.csv", header=T, sep=",") %>% head(15)
#  Check type of variable
# str(data)
# Since my time is currently a factor, I have to convert it to a date-time format!
data1$datetime <- ymd_hms(data1$datetime)
# Then you can create the xts necessary to use dygraph
don1 <- xts(x = data1$Clicks, order.by = data1$datetime)

don2 <- xts(x = data1$Keys, order.by = data1$datetime)

data2 <- read.xlsx("C:/Users/ADRIAN CAFA/Desktop/bd_tp_final/teclas_pulsadas_semanalmente.xlsx", sheetIndex = 1)

#Convert numeric columns to a numeric data type
data2$Keycount <- as.numeric(data2$Keycount)

data3 <- read.xlsx("C:/Users/ADRIAN CAFA/Desktop/bd_tp_final/teclas_pulsadas_semanalmente4.xlsx", sheetIndex = 1)
char_frequencies <- as.data.frame(data3)
char_frequencies$Freq <- char_frequencies$Freq * 100/sum(char_frequencies$Freq) 

treemap <- treemap(data2, #Your data frame object
             index=c("Keyname"),  #A list of your categorical variables
             vSize = "Keycount",  #This is your quantitative variable
             type="index", #Type sets the organization and color scheme of your treemap
             palette = "Reds"  #Select your color palette from the RColorBrewer presets or make your own.
          
)

data4 <- read.xlsx("C:/Users/ADRIAN CAFA/Desktop/bd_tp_final/applications2.xlsx", sheetIndex = 1)


```

PAGE 1
=======================================================================

Row
-----------------------------------------------------------------------

### Clicks-mouse

```{r}
p1 <- dygraph(don1) %>%
  dySeries("V1", label = "Clicks-mouse") %>%
  dyOptions(labelsUTC = TRUE, fillGraph=TRUE, fillAlpha=0.1, drawGrid = FALSE, colors="#D8AE5A") %>%
  dyRangeSelector() %>%
  dyCrosshair(direction = "vertical") %>%
  dyHighlight(highlightCircleSize = 5, highlightSeriesBackgroundAlpha = 0.2, hideOnMouseOut = FALSE)
myWidget1 <- combineWidgets(p1)
myWidget1
```


### Keys-keyboard 

```{r}
don2 <- xts(x = data1$Keys, order.by = data1$datetime)
p2 <- dygraph(don2) %>%
  dySeries("V1", label = "Keys-keyboard") %>%
  dyOptions(labelsUTC = TRUE, fillGraph=TRUE, fillAlpha=0.1, drawGrid = FALSE, colors="#D8AE5A") %>%
  dyRangeSelector() %>%
  dyCrosshair(direction = "vertical") %>%
  dyHighlight(highlightCircleSize = 5, highlightSeriesBackgroundAlpha = 0.2, hideOnMouseOut = FALSE)
myWidget2 <- combineWidgets(p2)
myWidget2
```

Row
-----------------------------------------------------------------------

### TreeMap of keyboards keys usage 

```{r}
p3 <- d3tree2( treemap)
myWidget3 <- combineWidgets(p3)
myWidget3
```

### % letters keys usage 

```{r}
cloud <- ggplot(char_frequencies, aes(x=letter, y = Freq)) +
  geom_point(size = 5) + 
  geom_segment(aes(x=letter, y = 0, xend = letter, yend = Freq), size = 1.1) +
  theme_classic() + 
  geom_hline(yintercept = 0) +
  geom_text(aes(label = letter), colour = "white", nudge_y = 0.05) +
  labs(y = "% letters frequency") + 
  # coord_flip() + 
  theme(axis.line.x = element_blank(), axis.text.x = element_blank(), axis.ticks.x = element_blank(), axis.title.x = element_blank())
cloud <- ggplotly(autosize = F)
cloud
```

PAGE 2
=======================================================================

Row
-----------------------------------------------------------------------

### Clicks mouse in Applications

```{r}
fig1 <- plot_ly(data4, x = ~Name, y = ~Clicks,type = 'scatter', mode = 'markers', size = ~Clicks, color = ~Name, colors = 'Paired',
               marker = list(opacity = 0.5, sizemode = 'diameter'))
fig1 <- fig1 %>% layout(
                      xaxis = list(showgrid = FALSE),
                      yaxis = list(showgrid = FALSE),
                      showlegend = FALSE,
                      autosize = T)
fig1
```

PAGE 3
=======================================================================

Row
-----------------------------------------------------------------------


### Keys keyboard in Applications

```{r}
fig2 <- plot_ly(data4, x = ~Name, y = ~Keys,type = 'scatter', mode = 'markers', size = ~Keys, color = ~Name, colors = 'Paired',
                marker = list(opacity = 0.5, sizemode = 'diameter'))
fig2 <- fig2 %>% layout(
                       xaxis = list(showgrid = FALSE),
                       yaxis = list(showgrid = FALSE),
                       showlegend = FALSE,
                       autosize = T)

fig2
```